package com.ttl.bc.ar.reqconfirm.bean;

import org.displaytag.decorator.TableDecorator;

import com.ttl.bc.ap.stkrequest.BCStkRequestShowBean;



public class BCReqConfirmAllDecorator extends TableDecorator {
	
	public String getQty1() {						
		BCStkRequestShowBean obj = (BCStkRequestShowBean)getCurrentRowObject();
		float qty = obj.getQty();
				
		return "<label align = 'right'>"+qty+"</label>";

	}
	
	public String getIttl_status() {
		BCStkRequestShowBean obj = (BCStkRequestShowBean)getCurrentRowObject();
		
		if (obj.getIttl_status()!=null && obj.getIttl_status().equals("0")) {
			return "รอเบิก";
		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("1")) {
			return "รอซื้อ";
		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("2")) {
			return "ซื้อแล้ว";
		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("3")) {
			return "จ่ายแล้ว";			
		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("-1")) {
			return "ยกเลิกขอซื้อ";
		}else {
			return "ค่า ittl_tatus ผิด";
		}
	}
	
	public String getMode() {		
		
		BCStkRequestShowBean obj = (BCStkRequestShowBean)getCurrentRowObject();
		String docNo = obj.getDocNo();				
		
		int inPage = getListIndex()/50+1;		

//	ตอนเดินงานด้วยระบบจัดซื้อ ittl_status =0,1 ต้องแยกไปตามแต่กรณีตัวเอง
		
		if (obj.getIttl_status()!=null && 
				( obj.getIttl_status().equals("2") || obj.getIttl_status().equals("0") || obj.getIttl_status().equals("1")) ) {
			
			return "<center><a href=\"/ittl/buyRequest/reqConfirm.do?mode=approveShow&docNo="+docNo+
					"&d-49653-p="+inPage+"\">จ่ายของ</a></center>";
		}else if (obj.getIttl_status()!=null & obj.getIttl_status().equals("3")) {
			
			return "<center><a href=\"/ittl/buyRequest/reqConfirm.do?mode=approveShowCancel&docNo="+docNo+
					"&d-49653-p="+inPage+"\">ยกเลิกการจ่าย</a></center>";	
			
//		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("0")) {
//			return "รอเบิก";
//		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("1")) {
//			return "รอซื้อ";
		}else {
			return "ค่า ittl_tatus ผิด";
		}
	}
}
